package admin

import "object/go_cms/models"

type UploadFileTypeAdminController struct {
	BaseAdminController
	models models.UploadTypeModels
}

// @router /admin/upload_file_type/indexUI [get]
func (c *UploadFileTypeAdminController) IndexUI() {
	c.TplAdmin("upload_file/type_index")
}

// @router /admin/upload_file_type/addUI [get]
func (c *UploadFileTypeAdminController) AddUI() {
	c.TplAdmin("upload_file/type_add")
}

// @router /admin/upload_file_type/editUI [get]
func (c *UploadFileTypeAdminController) EditUI() {
	c.TplAdmin("upload_file/type_edit")
}

// @router /admin/upload_file_type/get [get,post]
func (c *UploadFileTypeAdminController) Get() {
	id, _ := c.GetInt64("id")
	c.Res.Data, _ = c.models.Get(id)
	c.Json(c.Res)
}

// @router /admin/upload_file_type/query [get,post]
func (c *UploadFileTypeAdminController) Query() {
	c.Res.Data, _ = c.models.Query()
	c.Json(c.Res)
}

// @router /admin/upload_file_type/add [post]
func (c *UploadFileTypeAdminController) Add() {
	c.Res.Code = 1
	c.Res.Msg = "添加成功"
	maps := c.GetParamMap()
	_, err := c.models.Insert(maps)
	if err != nil {
		c.Res.Code = 0
		c.Res.Msg = err.Error()
	}
	c.Json(c.Res)
}

// @router /admin/upload_file_type/edit [post]
func (c *UploadFileTypeAdminController) Edit() {
	c.Res.Code = 1
	c.Res.Msg = "修改成功"
	maps := c.GetParamMap()
	_, err := c.models.Update(maps)
	if err != nil {
		c.Res.Code = 0
		c.Res.Msg = err.Error()
	}
	c.Json(c.Res)
}

// @router /admin/upload_file_type/delete [post]
func (c *UploadFileTypeAdminController) Delete() {
	id, _ := c.GetInt64("id")
	c.Res.Code = 1
	c.Res.Msg = "删除成功"
	_, err := c.models.Delete(id)
	if err != nil {
		c.Res.Code = 0
		c.Res.Msg = err.Error()
	}
	c.Json(c.Res)
}
